package com.oocl.euc.core.requestform.controller;

import com.oocl.euc.core.requestform.model.RequestRemarks;
import com.oocl.euc.core.requestform.service.RequestRemarksService;
import com.oocl.euc.core.requestform.vo.ConversationHistoryVO;
import com.oocl.euc.core.requestform.vo.RequestRemarksVO;
import com.oocl.euc.framework.base.controller.RESTController;
import com.oocl.euc.framework.base.service.BaseService;
import com.oocl.euc.framework.common.utils.ResponseEntityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/rest/requestRemarks")
public class RequestRemarksController extends RESTController<RequestRemarks, Long> {

    @Autowired
    private RequestRemarksService requestRemarksService;

    @Override
    protected BaseService<RequestRemarks, Long> getBaseService() {
        return requestRemarksService;
    }

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ResponseEntity addOneConversationRequestRemarks(@RequestBody RequestRemarksVO requestRemarksVO)throws Exception {
        RequestRemarks requestRemarks = requestRemarksService.addOneConversationRequestRemarks(requestRemarksVO);
        return ResponseEntityUtil.successInRestful(requestRemarks);
    }

    @RequestMapping(value = "/refNo/{refNo}", method = RequestMethod.GET)
    public ResponseEntity findConversationHistoryVOByRefNo(@PathVariable("refNo") String refNo) {
        List<ConversationHistoryVO> conversationHistoryVOList = requestRemarksService.findConversationHistoryVOByRefNo(refNo);
        return ResponseEntityUtil.successInRestful(conversationHistoryVOList);
    }
}
